package com.wuyou.designPatterns.interpreter;


/**
 * @Description <primitive command > ::= go | right | left
 * @Author 无忧
 * @Date 2024/10/20 21:57
 */
public class PrimitiveCommandNode extends Node{

    private String name;

    @Override
    public void parse(Context context) throws ParseException {
        name = context.currentToken();
        context.skipToken(name);
        if (!name.equals("go") && !name.equals("right") && !name.equals("left")) {
            throw new ParseException(name + " is undefined");
        }
    }

    public String toString(){
        return name;
    }
}
